//
//  CNArray.swift
//  YiZhangGui
//
//  Created by 卢逢卫 on 2024/4/2.
//

import Foundation

extension Array {
//    public subscript(safe index: Int) -> Element? {
//        return indices.contains(index) ? self[index] : nil
//    }
    
    public subscript(safe index: Int) -> Element? {
           guard index >= 0, index < count else {
               return nil
           }
           return self[index]
       }

    public var cn_dataValue: Data {
        return try! JSONSerialization.data(withJSONObject: self, options: [])
    }
}
